package com.jyy.demo.controller;

import com.jyy.demo.serivce.DemoService;
import com.jyy.utils.dynamicdatasource.DynamicBaseQuery;
import com.jyy.utils.dynamicdatasource.annotation.DataSource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * demo
 *
 * @author jyy
 * @date 2025-02-05
 */
@Slf4j
@RestController
@RequestMapping("/demo")
@RequiredArgsConstructor
public class DemoController {

    private final DemoService demoService;

    /**
     * 测试多数据源
     *
     * @param query 入参
     * @return String
     */
    @DataSource
    @GetMapping("/testDynamic")
    public String testDynamic(DynamicBaseQuery query) {
        // 测试多数据源
        String name = demoService.testDynamic(query);
        log.info("name:{}", name);
        return name;
    }
}
